/*
 * GUIEscolher.java
 *
 * Created on 10 de Setembro de 2007, 09:19
 */

package codebreaker.cliente.jogo.gui;

import codebreaker.cliente.Main;
import codebreaker.cliente.sala.Sala;
import javax.swing.JFrame;

/**
 *
 * @author  rodrigo
 */
public class GUIEscolher extends javax.swing.JFrame {
    
    private String nome, nomeAdv;
    
    /** Creates new form GUIEscolher */
    public GUIEscolher(String nomeAdv) {
	initComponents();

	this.nomeAdv = nomeAdv;
	
	Main.guiJogo = new GUIJogo(nomeAdv);
	Main.sala.setJogoListener(Main.guiJogo);
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc=" Código Gerado ">//GEN-BEGIN:initComponents
    private void initComponents() {
        btnOk = new javax.swing.JButton();
        canvasSenha = canvasSenha = new CanvasSenha();

        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        setTitle("Escolha sua Senha");
        setName("frameEscolha");
        setResizable(false);
        btnOk.setText("Ok");
        btnOk.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnOkActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, btnOk)
                    .add(canvasSenha, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 140, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .add(canvasSenha, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 43, Short.MAX_VALUE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(btnOk)
                .addContainerGap())
        );
        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnOkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOkActionPerformed
	/* envia senha gerada para servidor */
	Main.sala.enviar(new codebreaker.protocolo.Chute(((CanvasSenha)canvasSenha).getSenha()));
	
	/* vai para proxima tela, do jogo */	
	Main.guiJogo.setSenha(((CanvasSenha)canvasSenha).getSenha());
	Main.guiJogo.setVisible(true);
	this.setVisible(false);
    }//GEN-LAST:event_btnOkActionPerformed
        
    // Declaração de variáveis - não modifique//GEN-BEGIN:variables
    private javax.swing.JButton btnOk;
    private java.awt.Canvas canvasSenha;
    // Fim da declaração de variáveis//GEN-END:variables
    
}
